<template>
  <el-dialog
    v-model="visible"
    v-if="load"
    title="批量删除"
    width="600"
    draggable
    @close="close"
    :z-index="2000"
  >
    <template #default>
      <div class="flex items-center font-medium text-base">
        <svg-icon class="base-red-color mr-2" icon-class="hint_cover2"></svg-icon>
        <span
          >确认删除选中的
          <span class="text-blue-500 font-semibold">{{ skuIds.length }}</span>
          条商品信息？</span
        >
      </div>
      <div class="text-gray-500 ml-6 mt-2">只允许删除“待处理”“审核未通过”的商品信息</div>
    </template>
    <template #footer>
      <el-button class="btnFalses" :loading="loading" @click="save(formRef)"
        >删除</el-button
      >
      <el-button @click="close">取消</el-button>
    </template>
  </el-dialog>
</template>
<script setup name="SubmitAudit">
import { skuRecycle } from "../api";
import { reactive, toRefs, getCurrentInstance } from "vue";
import { ElMessage } from "element-plus";
const { proxy } = getCurrentInstance();
const emits = defineEmits(["query"]);
const data = reactive({
  skuIds: [],
  visible: false,
  loading: false,
  rules: {
    reviewer_id: [{ required: true, message: "请选择开发人员" }],
  },
  load: false,
});
const { visible, loading, skuIds, load } = toRefs(data);
const open = async (ids) => {
  if (!load.value) {
    load.value = true;
    await 1;
  }
  if (ids) skuIds.value = ids;
  visible.value = true;
};
const save = () => {
  loading.value = true;
  skuRecycle({ skuIds: skuIds.value })
    .then((res) => {
      ElMessage.success(res.message);
      emits("query");
      close();
    })
    .finally(() => {
      loading.value = false;
    });
};
const close = () => {
  proxy.resetForm("formRef");
  visible.value = false;
};
defineExpose({ open });
</script>
